﻿@model SpyApp.Models.CustomPageList<SpyApp.Models.User>
@*@model IEnumerable<SpyApp.Models.User>*@

@using SpyApp.Helpers;

@{
    ViewBag.Title = "Account Manage";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

<div class="page-header">
    <h3>@ViewBag.Title</h3>
</div>

@using (Html.BeginRouteForm(null, FormMethod.Get))
{
    <div class="form-row">
        <div class="form-column medium-12">
            @Html.TextBox(SpyApp.Models.BaseCommon.Enum.StaticValue.QUICK_SEARCH_STRING,
            Request.QueryString[SpyApp.Models.BaseCommon.Enum.StaticValue.QUICK_SEARCH_STRING])
            @Html._SubmitButton("Search")
        </div>
    </div>
}

<nav id="main-page-list-1">
    <script>
        document.getElementById("main-page-list-1").appendChild(
            getPageList(
            '@Model.PageCount',
            '@Model.PageIndex',
            '@SpyApp.Models.BaseCommon.Enum.StaticValue.CURRENT_PAGE'));
    </script>
</nav>

<div class="table-contain">
    <table class="max-width">
        <thead>
            <tr>
                <th>
                    
                </th>
                <th>
                    @Html._DisplayNameFor(Model.ListCustom, m => m.Id)
                </th>
                <th>
                    @Html._DisplayNameFor(Model.ListCustom, m => m.UserName)
                </th>
                <th>
                    @Html._DisplayNameFor(Model.ListCustom, m => m.PassWord)
                </th>
                <th>
                    @Html._DisplayNameFor(Model.ListCustom, m => m.Age)
                </th>
                <th>
                    @Html._DisplayNameFor(Model.ListCustom, m => m.TotalLogin)
                </th>
                <th>
                    @Html._DisplayNameFor(Model.ListCustom, m => m.ActiveInvationCode)
                </th>
                <th>
                    @Html._DisplayNameFor(Model.ListCustom, m => m.UserInRoles)
                </th>
                <th>
                    @Html._DisplayNameFor(Model.ListCustom, m => m.UserStatus)
                </th>
                <th>
                    @Html._DisplayNameFor(Model.ListCustom, m => m.Status)
                </th>
                <th>
                    @Html._DisplayNameFor(Model.ListCustom, m => m.UserType)
                </th>
                <th>
                    @Html._DisplayNameFor(Model.ListCustom, m => m.LastModifined)
                </th>
            </tr>
        </thead>
        <tbody>
            @if (Model.ListCustom == null)
            {
                <tr>
                    <td colspan="100%">
                        null
                    </td>
                </tr>
            }
            else 
            {
            foreach (var item in Model.ListCustom)
            {
                <tr>
                    <td class="nowrap">
                        @Html.ActionLink("Edit", "EditAccount", new {id = item.Id}, null)
                    </td>
                    <td>
                        @item.Id
                    </td>
                    <td>
                        @item.UserName
                    </td>
                    <td>
                        @item.PassWord
                    </td>
                    <td>
                        @item.Age
                    </td>
                    <td>
                        @item.TotalLogin
                    </td>
                    <td>
                        @item.ActiveInvationCode
                    </td>
                    <td>
                        @if (item.UserInRoles != null)
                        { 
                            foreach (var role in item.UserInRoles)
                            {
                                <p>@role.RoleName</p>
                            }
                        }
                    </td>
                    <td>
                        @item.UserStatus
                    </td>
                    <td>
                        @item.Status
                    </td>
                    <td>
                        @item.UserType
                    </td>
                    <td>
                        @item.LastModifined
                    </td>
                </tr>   
            }
            }
        </tbody>
        <tfoot>
        </tfoot>
    </table>
</div>
<nav id="main-page-list-2">
    <script>
        document.getElementById("main-page-list-2").appendChild(
            getPageList(
            '@Model.PageCount',
            '@Model.PageIndex',
            '@SpyApp.Models.BaseCommon.Enum.StaticValue.CURRENT_PAGE'));
    </script>
</nav>
